<template>
  <div>
    <el-card>
      <ECharts :options="chartOptions" />
    </el-card>
  </div>
</template>

<script>
import axios from 'axios';
import ECharts from '@/components/ECharts.vue';
import {groupById} from "@/api/system/pro";


export default {
  components: { ECharts },
  data() {
    return {
      chartOptions: {
        title: {
          text: '商品统计'
        },
        tooltip: {},
        xAxis: {
          type: 'category',
          data: []
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '商品数量',
            type: 'line',
            data: []
          }
        ]
      }
    };
  },
  mounted() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      groupById().then(response => {
        console.log(response+"resonds")
        const data = response;
        this.chartOptions.xAxis.data = data.map(item => item.date);
        this.chartOptions.series[0].data = data.map(item => item.count);
      });
    }
  }
};
</script>

<style scoped>
</style>
